﻿Feature: Depencency Inversion
	As an application component, I want the ability to invert all of my dependencies.
	This means being able to register any class type under any name or any other compatible service type.
	It also means being able to recursively resolve both constructor and property injection values when retrieving objects.
	Finally, it means being able to assign my own instances as singleton services.

Scenario Outline: Simple Happy Path
	Given I have created a <Container>-based registry
	When I register a type
	And I resolve the type I registered
	Then the result should be a non-null instance of the requested type
	Scenarios:
		| Container     |
		| Autofac       |
		| CastleWindsor |
		| LinFu         |
		| Mef           |
		| Ninject       |
		| Spring        |
		| StructureMap  |
		| Unity         |

Scenario Outline: Complex Happy Path
	Given I have created a <Container>-based registry
	When I register a complex inverted type
	And I add a name to the registration
	And I add a service type to the registration
	And I add a runtime constructor with arguments to the registration
	And I resolve the type I registered by name, providing the required arguments
	And I resolve the type I registered by service type, providing the required arguments
	Then the first result should be a non-null instance of the requested type
	And the second result should be a non-null instance of the requested type
	And the first result and the second result should not be the same object
	Scenarios:
		| Container     |
		| Autofac       |
		| CastleWindsor |
		| LinFu         |
		| Mef           |
		| Ninject       |
		| Spring        |
		| StructureMap  |
		| Unity         |

Scenario Outline: Dependency Failure (missing one)
	Given I have created a <Container>-based registry
	When I register a complex inverted type but omit a dependency
	And I resolve the type I registered
	Then I should receive a resolution error stating that a dependency was not found
	And the error should state which dependency is missing
	Scenarios:
		| Container     |
		| Autofac       |
		| CastleWindsor |
		| LinFu         |
		| Mef           |
		| Ninject       |
		| Spring        |
		| StructureMap  |
		| Unity         |

Scenario Outline: Auto Resolve
	Given I have created a <Container>-based registry
	And I have calibrated the container to automatically resolve dependencies
	When I resolve an unregistered complex inverted type
	Then the result should be a non-null instance of the requested type
	Scenarios:
		| Container     |
		| Autofac       |
		| CastleWindsor |
		| LinFu         |
		| Mef           |
		| Ninject       |
		| Spring        |
		| StructureMap  |
		| Unity         |

Scenario Outline: Singleton
	Given I have created a <Container>-based registry
	When I register an instance of a complex inverted type
	And I resolve the type I registered
	Then the result and the original instance should be the same object
	Scenarios:
		| Container     |
		| Autofac       |
		| CastleWindsor |
		| LinFu         |
		| Mef           |
		| Ninject       |
		| Spring        |
		| StructureMap  |
		| Unity         |